﻿namespace AladdinGameFramework
{
	public static partial class Utility
	{
		/// <summary>
		/// 性能分析相关函数
		/// </summary>
		[DontProfile]
		public static partial class Profiler
		{
			private static IProfilerHelper s_ProfilerHelper = null;

			/// <summary>
			/// 设置性能分析辅助器
			/// </summary>
			/// <param name="profileHelper">要设置的性能分析辅助器</param>
			public static void SetProfilerHelper(IProfilerHelper profileHelper)
			{
				s_ProfilerHelper = profileHelper;
			}

			/// <summary>
			/// 开始采样
			/// </summary>
			/// <param name="name"></param>
			public static void BeginSample(string name)
			{
				if (s_ProfilerHelper == null)
					throw new GameFrameworkException("Profile helper is invalid");
				s_ProfilerHelper.BeginSample(name);
			}

			/// <summary>
			/// 结束采样
			/// </summary>
			public static void EndSample()
			{
				if (s_ProfilerHelper == null)
					throw new GameFrameworkException("Profile helper is invalid.");

				s_ProfilerHelper.EndSample();
			}
		}
	}
}
